package br.com.leilao.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class ConectaBanco {
	public static Connection getConnection() throws  ClassNotFoundException, SQLException{
	  final String url = "jdbc:mysql://127.0.0.1:3306/dbleilao";
	  Connection con = 	DriverManager.getConnection(url, "root", "12345");
	  return con;
	}
	public static void closeAll(Connection con) {
        try {
            if (con != null) {
                con.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void closeAll(Connection con, Statement stmt, ResultSet rs) {
        try {
            if (con != null || stmt != null) {
                closeAll(con, stmt);
            }
            if (rs != null) {
                rs.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void closeAll(Connection con, Statement stmt) {
        try {
            if (con != null) {
                closeAll(con);
            }
            if (stmt != null) {
                stmt.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
